const { createProxyMiddleware } = require('http-proxy-middleware');

// According to:
// https://create-react-app.dev/docs/proxying-api-requests-in-development/#configuring-the-proxy-manually
module.exports = function(app) {
  app.use(
    '/douban-img',
    createProxyMiddleware({
      target: 'https://img9.doubanio.com',
      changeOrigin: true,
      pathRewrite: {
        '^/douban-img' : '/'
      },
      headers: {
        "Referer": "https://movie.douban.com"
      }
    })
  );
  app.use(
    '/douban-api',
    createProxyMiddleware({
      target: 'https://movie.douban.com',
      changeOrigin: true,
      pathRewrite: {
        '^/douban-api': '/',
      },
      headers: {
        Referer: 'https://movie.douban.com',
      },
    })
  )
};

